|
Eclipse Platform Pre-release 3.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jface.text.source.AnnotationModel
Standard implementation of IAnnotationModel
. This class can directly
be used by clients. Subclasses may adapt this annotation model to other existing
annotation mechanisms.
Field Summary | |
protected ArrayList |
fAnnotationModelListeners
The list of annotation model listeners |
protected Map |
fAnnotations
The list of managed annotations |
protected IDocument |
fDocument
The document connected with this model |
Constructor Summary | |
AnnotationModel()
Creates a new annotation model. |
Method Summary | |
void |
addAnnotation(Annotation annotation,
Position position)
Adds a annotation to this annotation model. |
protected void |
addAnnotation(Annotation annotation,
Position position,
boolean fireModelChanged)
Adds the given annotation to this model. |
void |
addAnnotationModel(Object key,
IAnnotationModel attachment)
Attaches attachment to the receiver. |
void |
addAnnotationModelListener(IAnnotationModelListener listener)
Registers the annotation model listener with this annotation model. |
protected void |
addPosition(IDocument document,
Position position)
Adds the given position to the default position category of the given document. |
protected void |
cleanup(boolean fireModelChanged)
Removes all annotations from the model whose associated positions have been deleted. |
void |
connect(IDocument document)
Connects the annotation model to a document. |
protected void |
connected()
Hook method. |
protected AnnotationModelEvent |
createAnnotationModelEvent()
Creates and returns a new annotation model event. |
void |
disconnect(IDocument document)
Disconnects this model from a document. |
protected void |
disconnected()
Hook method. |
protected void |
fireModelChanged()
Informs all annotation model listeners that this model has been changed. |
protected void |
fireModelChanged(AnnotationModelEvent event)
Informs all annotation model listeners that this model has been changed as described in the annotation model event. |
Iterator |
getAnnotationIterator()
Returns all annotations managed by this model. |
protected Iterator |
getAnnotationIterator(boolean cleanup)
Returns all annotations managed by this model. |
IAnnotationModel |
getAnnotationModel(Object key)
Returns the attached IAnnotationModel for key , or null
if none is attached for key . |
Position |
getPosition(Annotation annotation)
Returns the position associated with the given annotation. |
void |
modifyAnnotation(Annotation annotation,
Position position)
Modifies the position associated with the given annotation to the given position. |
protected void |
modifyAnnotation(Annotation annotation,
Position position,
boolean fireModelChanged)
Modifies the associated position of the given annotation to the given position. |
void |
removeAllAnnotations()
Removes all annotations from the annotation model and informs all model listeners about this change. |
protected void |
removeAllAnnotations(boolean fireModelChanged)
Removes all annotations from the annotation model. |
void |
removeAnnotation(Annotation annotation)
Removes the given annotation from the model. |
protected void |
removeAnnotation(Annotation annotation,
boolean fireModelChanged)
Removes the given annotation from the annotation model. |
IAnnotationModel |
removeAnnotationModel(Object key)
Removes and returns the attached IAnnotationModel for key . |
void |
removeAnnotationModelListener(IAnnotationModelListener listener)
Removes the listener from the model's list of annotation model listeners. |
protected void |
removeAnnotations(List annotations,
boolean fireModelChanged,
boolean modelInitiated)
Removes the given annotations from this model. |
void |
replaceAnnotations(Annotation[] annotationsToRemove,
Map annotationsToAdd)
Replaces annotations with new annotations for this annotation model. |
protected void |
replaceAnnotations(Annotation[] annotationsToRemove,
Map annotationsToAdd,
boolean fireModelChanged)
Replaces the given annotations in this model and if advised fires a model change event. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Map fAnnotations
protected ArrayList fAnnotationModelListeners
protected IDocument fDocument
Constructor Detail |
public AnnotationModel()
Method Detail |
public void addAnnotation(Annotation annotation, Position position)
IAnnotationModel
addAnnotation
in interface IAnnotationModel
annotation
- the annotation to add, may not be null
position
- the position describing the range covered by this annotation,
may not be null
public void replaceAnnotations(Annotation[] annotationsToRemove, Map annotationsToAdd)
IAnnotationModelExtension
replaceAnnotations
in interface IAnnotationModelExtension
annotationsToRemove
- the annotations to be removed, may be null
annotationsToAdd
- the annotations which will be added, may be null
each map entry has an Annotation
as key and a Position
as valueprotected void replaceAnnotations(Annotation[] annotationsToRemove, Map annotationsToAdd, boolean fireModelChanged) throws BadLocationException
annotationsToRemove
- the annotations to be removedannotationsToAdd
- the annotations to be addedfireModelChanged
- true
if a model change event
should be fired, false
otherwise
BadLocationException
- in case an annotation should be added at an
invalid positionprotected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException
annotation
- the annotation to addposition
- the associate position
BadLocationException
- if the position is not a valid document positionpublic void addAnnotationModelListener(IAnnotationModelListener listener)
IAnnotationModel
addAnnotationModelListener
in interface IAnnotationModel
listener
- the listener to be registered, may not be null
protected void addPosition(IDocument document, Position position) throws BadLocationException
document
- the document to which to add the positionposition
- the position to add
BadLocationException
- if the position is not a valid document positionpublic void connect(IDocument document)
IAnnotationModel
connect
calls must mention the document the
model is already connected to. An annotation model primarily uses
connect
and disconnect
for reference counting
the document. Reference counting frees the clients from keeping tracker
whether a model has already been connected to a document.
connect
in interface IAnnotationModel
document
- the document the model gets connected to,
may not be null
IAnnotationModel.disconnect(org.eclipse.jface.text.IDocument)
protected void connected()
protected void disconnected()
public void disconnect(IDocument document)
IAnnotationModel
disconnect
in interface IAnnotationModel
document
- the document the model gets disconnected from,
may not be null
for further specification details
protected void fireModelChanged()
protected AnnotationModelEvent createAnnotationModelEvent()
protected void fireModelChanged(AnnotationModelEvent event)
IAnnotationModelListenerExtension
.
All other listeners are notified by just calling modelChanged(IAnnotationModel)
.
event
- the event to be sent out to the listenersprotected void removeAnnotations(List annotations, boolean fireModelChanged, boolean modelInitiated)
modelInitiated
indicates whether the deletion has
been initiated by this model or by one of its clients.
annotations
- the annotations to be removedfireModelChanged
- indicates whether to notify all model listenersmodelInitiated
- indicates whether this changes has been initiated by this modelprotected void cleanup(boolean fireModelChanged)
fireModelChanged
- indicates whether to notify all model listenerspublic Iterator getAnnotationIterator()
IAnnotationModel
getAnnotationIterator
in interface IAnnotationModel
protected Iterator getAnnotationIterator(boolean cleanup)
cleanup
indicates whether all annotations whose associated positions are
deleted should previously be removed from the model.
cleanup
- indicates whether annotations with deleted associated positions are removed
public Position getPosition(Annotation annotation)
IAnnotationModel
getPosition
in interface IAnnotationModel
annotation
- the annotation whose position should be returned
null
if no
associated annotation existspublic void removeAllAnnotations()
protected void removeAllAnnotations(boolean fireModelChanged)
fireModelChanged
- indicates whether to notify all model listenerspublic void removeAnnotation(Annotation annotation)
IAnnotationModel
removeAnnotation
in interface IAnnotationModel
annotation
- the annotation to be removed from this model,
may not be null
protected void removeAnnotation(Annotation annotation, boolean fireModelChanged)
annotation
- the annotation to be removedfireModelChanged
- indicates whether to notify all model listenerspublic void modifyAnnotation(Annotation annotation, Position position)
annotation
- the annotation whose associated position should be
modifiedposition
- the position to whose values the associated position
should be changedprotected void modifyAnnotation(Annotation annotation, Position position, boolean fireModelChanged)
annotation
- the annotation whose associated position should be
modifiedposition
- the position to whose values the associated position
should be changedfireModelChanged
- indicates whether to notify all model listenerspublic void removeAnnotationModelListener(IAnnotationModelListener listener)
IAnnotationModel
removeAnnotationModelListener
in interface IAnnotationModel
listener
- the listener to be removed, may not be null
public void addAnnotationModel(Object key, IAnnotationModel attachment)
IAnnotationModelExtension
attachment
to the receiver. Connects attachment
to
the currently connected document. If attachment
is already attached (even)
under a different key), it is not attached again.
addAnnotationModel
in interface IAnnotationModelExtension
key
- the key through which the attachment is identified.attachment
- the attached IAnnotationModel
public IAnnotationModel getAnnotationModel(Object key)
IAnnotationModelExtension
IAnnotationModel
for key
, or null
if none is attached for key
.
getAnnotationModel
in interface IAnnotationModelExtension
key
- the key through which the attachment is identified.
IAnnotationModel
attached under key
, or null
public IAnnotationModel removeAnnotationModel(Object key)
IAnnotationModelExtension
IAnnotationModel
for key
.
removeAnnotationModel
in interface IAnnotationModelExtension
key
- the key through which the attachment is identified.
IAnnotationModel
attached under key
, or null
|
Eclipse Platform Pre-release 3.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |